package org.hxzon.demo.jt.logsearcher.util;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.cjk.CJKAnalyzer;
import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.util.Version;

public class LogSearcherConfig {

    public static final String IndexFileBaseDir = "D:/work-juntai/训练题/文本全文检索应用-测试数据/hxzon/";
    public static final String LogFileEncoding = "gbk";
    //
    public static final Version LuceneVersion = Version.LUCENE_45;
    public static final String FieldName_LogTime = "logTime";
    public static final String FieldName_Content = "content";
    //-------
    public static final Analyzer StandardAnalyzer = new StandardAnalyzer(LuceneVersion);
    public static final Analyzer CjkAnalyzer = new CJKAnalyzer(LuceneVersion);
    public static final Analyzer SmartChineseAnalyzer = new SmartChineseAnalyzer(LuceneVersion);

    //public static final Analyzer IndexAnalyzer = new ChineseAnalyzer();//Deprecated

    public static final Analyzer getAnalyzer(String name) {
        if ("std".equals(name)) {
            return StandardAnalyzer;
        } else if ("cjk".equals(name)) {
            return CjkAnalyzer;
        } else if ("smartCn".equals(name)) {
            return SmartChineseAnalyzer;
        } else {
            return StandardAnalyzer;
        }
    }
}
